<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.32">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #2c7014}
span.s1 {color: #303895}
span.s2 {color: #000000}
span.s3 {color: #001bb9}
span.s4 {color: #2c7014}
</style>
</head>
<body>
<p class="p1"><br></p>
<p class="p2"><b>AutoTrack</b></p>
<p class="p1"><br></p>
<p class="p2">Autocorrelation beat tracker by Nick Collins, following:</p>
<p class="p1"><br></p>
<p class="p3">M. E. P. Davies and M. D. Plumbley. <span class="s1">Beat Tracking With A Two State Model</span>. <i>Proceedings of the IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP 2005)</i>, Philadelphia, USA, March 19-23, 2005</p>
<p class="p1"><br></p>
<p class="p2">This is my own adaptation for my beat tracking research and uses my own C implementation of Matthew Davies' original MATLAB model. Meanwhile, Paul Brossier and Matthew have been preparing their own realtime version for Paul's aubio library. <span class="Apple-converted-space"> </span></p>
<p class="p1"><br></p>
<p class="p2">There are four k-rate outputs, being ticks at quarter, eighth and sixteenth level from the determined beat, and the current detected tempo.<span class="Apple-converted-space"> </span></p>
<p class="p1"><br></p>
<p class="p2">Note the following restrictions:</p>
<p class="p1"><br></p>
<p class="p2">This beat tracker determines the beat, biased to the midtempo range by weighting functions. It does not determine the measure level, only a tactus. It is also slow reacting, using a 6 second temporal window for it's autocorrelation maneouvres. Don't expect human musician level predictive tracking.<span class="Apple-converted-space"> </span></p>
<p class="p1"><br></p>
<p class="p2">On the other hand, it is tireless, relatively general (though obviously best at transient 4/4 heavy material without much expressive tempo variation), and can form the basis of computer processing that is decidedly faster than human.<span class="Apple-converted-space"> </span></p>
<p class="p1"><br></p>
<p class="p2"><b>Class Methods</b></p>
<p class="p1"><br></p>
<p class="p2"><b>*ar(in,lock)</b></p>
<p class="p1"><br></p>
<p class="p2"><b>in- </b>Audio input to track</p>
<p class="p1"><br></p>
<p class="p2"><b>lock- </b>If this argument is greater than 0.5, the tracker will lock at its current periodicity and continue from the current phase. Whilst it updates the model's phase and period, this is not reflected in the output until lock goes back below 0.5. <span class="Apple-converted-space"> </span></p>
<p class="p1"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p5">//choose some file you want to track off your hard drive (mono)</p>
<p class="p6"><span class="s2">b=</span><span class="s3">Buffer</span><span class="s2">.read(s,</span>"/data/audio/mirdata/stevebeattrack/samples/100.wav"<span class="s2">);</span></p>
<p class="p4"><br></p>
<p class="p7">(</p>
<p class="p7">a= <span class="s3">SynthDef</span>(<span class="s4">\help_autotrack</span>,{<span class="s3">arg</span> vol=1.0, beepvol=1.0, lock=0;</p>
<p class="p7"><span class="s3">var</span> trackb,trackh,trackq,tempo;</p>
<p class="p7"><span class="s3">var</span> source, beep;</p>
<p class="p4"><br></p>
<p class="p7">source= <span class="s3">PlayBuf</span>.ar(1,b.bufnum,1.0,1,0,1);</p>
<p class="p4"><br></p>
<p class="p7">#trackb,trackh,trackq,tempo=<span class="s3">AutoTrack</span>.kr(source, lock);</p>
<p class="p4"><br></p>
<p class="p7">beep= <span class="s3">SinOsc</span>.ar(1000,0.0,<span class="s3">Decay</span>.kr(trackb,0.1));</p>
<p class="p4"><br></p>
<p class="p7"><span class="s3">Out</span>.ar(0,<span class="s3">Pan2</span>.ar((vol*source)+(beepvol*beep),0.0));</p>
<p class="p4"><br></p>
<p class="p7">}).play;</p>
<p class="p7">)</p>
<p class="p4"><br></p>
<p class="p7">a.set(<span class="s4">\vol</span>,0.0);</p>
<p class="p4"><br></p>
<p class="p7">a.set(<span class="s4">\beepvol</span>,1.0);</p>
<p class="p4"><br></p>
<p class="p5"><span class="s2">a.set(</span><span class="s4">\lock</span><span class="s2">,1); </span>//fix it rigidly from current phase/period solution</p>
<p class="p4"><br></p>
<p class="p5"><span class="s2">a.set(</span><span class="s4">\lock</span><span class="s2">,0); </span>//unfix, back to tracking</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p5">//track audio in (try clapping a beat or beatboxing, but allow up to 6 seconds for tracking to begin) and spawning stuff at quarters, eighths and sixteenths</p>
<p class="p7">(</p>
<p class="p8"><span class="s3">SynthDef</span><span class="s2">(</span>\help_autotrack2<span class="s2">,{</span></p>
<p class="p7"><span class="s3">var</span> trackb,trackh,trackq,tempo;</p>
<p class="p7"><span class="s3">var</span> source;</p>
<p class="p7"><span class="s3">var</span> bsound,hsound,qsound;</p>
<p class="p4"><br></p>
<p class="p7">source= <span class="s3">AudioIn</span>.ar(1);</p>
<p class="p4"><br></p>
<p class="p7">#trackb,trackh,trackq,tempo=<span class="s3">AutoTrack</span>.kr(source);</p>
<p class="p4"><br></p>
<p class="p7">bsound= <span class="s3">Pan2</span>.ar(<span class="s3">LPF</span>.ar(<span class="s3">WhiteNoise</span>.ar*(<span class="s3">Decay</span>.kr(trackb,0.05)),1000),0.0);</p>
<p class="p4"><br></p>
<p class="p7">hsound= <span class="s3">Pan2</span>.ar(<span class="s3">BPF</span>.ar(<span class="s3">WhiteNoise</span>.ar*(<span class="s3">Decay</span>.kr(trackh,0.05)),3000,0.66),-0.5);</p>
<p class="p4"><br></p>
<p class="p7">qsound= <span class="s3">Pan2</span>.ar(<span class="s3">HPF</span>.ar(<span class="s3">WhiteNoise</span>.ar*(<span class="s3">Decay</span>.kr(trackq,0.05)),5000),0.5);</p>
<p class="p4"><br></p>
<p class="p7"><span class="s3">Out</span>.ar(0, bsound+hsound+qsound);</p>
<p class="p7">}).play;</p>
<p class="p7">)</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p4"><br></p>
</body>
</html>
